﻿using System;
using System.Text.RegularExpressions;

namespace Helpers
{
    public class AmazonHelper
    {
        /// <summary>
        /// 判断是否robot页面
        /// </summary>
        /// <param name="html">原生html</param>
        /// <returns>true-机器人页面</returns>
        public static void EnsureNotRobotCheckPage(string html)
        {
            //美国、英国、日本、德国
            if (Regex.IsMatch(html, "(Robot Check|Amazon CAPTCHA|Bot Check)</title>", RegexOptions.IgnoreCase))
                throw new AmazonUtils.RobotException();
        }

        /// <summary>
        /// 判断是否busy页面
        /// </summary>
        /// <param name="html">原生html</param>
        /// <returns>true-机器人页面</returns>
        public static bool IsServerBusyPage(string html)
        {
            return Regex.IsMatch(html, "Server Busy</title>");
        }

        /// <summary>
        /// 判断是否sorry页面
        /// </summary>
        /// <param name="html">原生html</param>
        /// <returns></returns>
        public static bool IsSorryPage(string html)
        {
            return Regex.IsMatch(html, "Page Not Found</title>");
        }

        
    }


}
